package com.QSystem.controller;

import com.QSystem.pojo.User;
import com.QSystem.pojo.WholeSurvey;
import com.QSystem.service.UserService;
import com.QSystem.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping
public class UserController {
    @Autowired
    UserService userService;
    @Autowired
    WholeSurvey wholeSurvey;
    User temp=new User();


    //验证登录
    @PostMapping(value = {"/login"},produces = {"application/json; charset=UTF-8"})
    public Result login(@RequestBody User body){
        //这是做什么来着，自己写的都忘了。。。。。。
        //userService.getUserId("admin");
        //查询用户账号，如果成功则获取该用户
        return userService.queryByName(body);
    }

    //注册
    @PostMapping(value = {"/register"},produces = {"application/json; charset=UTF-8"})
    public Result register(@RequestBody User body){
        //查询用户账号，如果成功则添加该用户
        return userService.register(body);
    }

}
